<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
    <h:head>
       <style type="text/css">
           .headerLabel{
               color:#ffb73d; 
               font-size:14pt; 
               font-weight:bold;
               padding-left:15px;
               padding-right:15px;
           }
           
           
       </style>
    </h:head>
    <h:body style="background-color: #111111">
        <ui:composition>
          <center>
            <div style="width: 800px; padding:0px; margin:0px"> 
              
                  <center>  
                     <h:form>
                        <p:graphicImage style="width: 800px" url="/images/jforum_logo.png"/>
                        
                        <p:menubar style="width: 780px">
                          <p:menuitem value="#{resourcesController.extractResource('MAIN_PAGE')}" url="/faces/index.xhtml"/>
                          <p:menuitem value="#{resourcesController.extractResource('FILESHARE')}" url="/faces/fileshare.xhtml"/>
                          <p:menuitem value="#{resourcesController.extractResource('LIVE_CHAT')}" url="/faces/livechat.xhtml"/>
                          <p:menuitem value="#{resourcesController.extractResource('REGISTRATION')}" url="/faces/registration.xhtml"/>
                          <p:menuitem value="#{resourcesController.extractResource('FORUM_SEARCH')}" onclick="searchbox.show();"/>
                          <c:if test="#{authorizationBean.user == null}">
                            <p:menuitem value="#{resourcesController.extractResource('LOG_IN')}" onclick="loginbox.show();"/>
                          </c:if>
                          <c:if test="#{authorizationBean.user != null}">
                              <p:menuitem value="#{resourcesController.extractResource('LOGOUT')}" action="#{authorizationBean.logout()}"/>
                          </c:if>
                        </p:menubar>
                     </h:form>  
                     <h:form>
                        <div align="left" style="float: left">
                            <h:outputText style="color:#ffb73d;font-size:14pt;font-weight:bold;padding-left:15px;padding-right:15px;" 
                                                    id="helloMessage"
                                                    rendered="true"
                                                    value="#{resourcesController.extractResource('HELLO')}, #{authorizationBean.username}!"/>
                            
                            <c:if test="#{authorizationBean.user!=null}">
                                    <h:commandLink action="/userinfo.xhtml?faces-redirect=true" style="float:right">
                                        <p:graphicImage url="/images/user.png"
                                                        height="20px"
                                                        />
                                    </h:commandLink>  
                            </c:if>
                        </div>
                            
                        <div align="right" styleClass="headerLabel">
                            <h:outputText style="color:#ffb73d;font-size:14pt;font-weight:bold;padding-left:15px;padding-right:15px;"  
                                          value="#{userSessionListener.currentConnections} #{resourcesController.extractResource('USERS_ONLINE')}"/> 
                        </div>
                      </h:form>
                    </center>
                  
                    <h:form>
                      <p:growl id="messageGrowl" showDetail="true"/>
                      <p:dialog header="#{resourcesController.extractResource('USER_AUTH')}"
                                widgetVar="loginbox"
                                width="400">
                          <h:panelGrid columns="2">
                            <h:outputLabel id="uname"   value="#{resourcesController.extractResource('LOGIN')}"/>
                            <p:inputText   id="inuname" value="#{authorizationBean.username}" size="15"/>
                            <h:outputLabel id="upass"   value="#{resourcesController.extractResource('PASSWORD')}"/>
                            
                            <p:password value="#{authorizationBean.password}"
                                     feedback="false"
                                     size="15"
                                     maxlength="18"
                                     id="inupass"
                                     required="true"

                                     requiredMessage="#{resourcesController.extractResource('PASSWORD_REQUIRED')}">
                                <p:ajax event="blur"  />
                            </p:password>  
                            
                            
                            <p:commandButton update="inuname inupass helloMessage"
                                             value="#{resourcesController.extractResource('LOG_IN')}"
                                             async="true"
                                             ajax="false"
                                             oncomplete="loginbox.hide();"
                                             action="#{authorizationBean.authorise}">
                                <f:ajax render="@all"/>
                            </p:commandButton>
                            <p:commandLink style="color:#0b93d5" 
                                           value="#{resourcesController.extractResource('PASSWORD_FORGOT')}" 
                                           onclick="restorebox.show();"/>
                          </h:panelGrid>
                      </p:dialog>
                  
                      
                  </h:form>
            
                  <h:form>
                      <p:dialog header="#{resourcesController.extractResource('PASSWORD_RESTORE')}"
                                widgetVar="restorebox"
                                width="400">
                         <h:panelGrid columns="2">
                            <h:outputLabel id="email" value="#{resourcesController.extractResource('ENTER_ADDRESS')}"/>
                            <p:inputText id="inemail" value="#{authorizationBean.email}" size="15"/>
                            <p:commandButton update="inemail"
                                             value="#{resourcesController.extractResource('RESTORE')}"
                                             async="true"
                                             oncomplete="restorebox.hide(); loginbox.hide();"
                                             actionListener="#{authorizationBean.restorePassword(authorizationBean.email)}"/>
                          </h:panelGrid>
                      </p:dialog>
                 </h:form>
                 <h:form>
                      <p:dialog header="#{resourcesController.extractResource('ENTER_SEARCH_PATTERN')}"
                                widgetVar="searchbox"
                                width="350">
                              <p:inputText value="#{searchBean.searchPattern}"
                                           size="20"/>
                                <p:commandLink actionListener="#{searchBean.searchPosts()}"
                                               action="/search.xhtml"       
                                               ajax="false" >
                                  <p:graphicImage url="/images/search_button.png"
                                                  style="float: right; height:35px"/>
                                </p:commandLink>
                      </p:dialog>
                 </h:form>
             </div>
           </center>
        </ui:composition>
    </h:body>
</html>

